package net.dfx.iot_download_tool.utils;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;

public class TrustAllUtil {
	/**
	 * 跳过SSL证书验证
	 * @param connection {@link HttpsURLConnection} 请求链接对象
	 * @throws Exception 抛出异常
	 */
	public void trustAllCertificates(HttpsURLConnection connection) throws Exception {
		SSLContext sc = SSLUtil.createAll();
		connection.setSSLSocketFactory(sc.getSocketFactory());
		connection.setHostnameVerifier(new TrustAllHostnameVerifier()); // 禁用主机名验证
	}
}